#ifndef __SUBCHARSOLUTION__
#define __SUBCHARSOLUTION__
#include <iostream>
/*
*<BPFPI> Test P86 1
* input two char sequences
* find the 2nd char sequence connective order in the other one
*/
class SubCharSolution{
 public:
	static void TestDrive(char * pStr, char * subStr){
		if(pStr == NULL || subStr == NULL){
			std::cerr << "Error" << std::endl;
			return;
		}
		int * solution = new int [strlen(subStr)];
		if(solution ==NULL){
			std::cerr << "No More Memory.."<< std::endl;
		}
		GetSolution(pStr, strlen(pStr), subStr, strlen(subStr), solution, 0, 0 ,0);
		delete solution;
	}
 private:
	static void GetSolution(char * pStr, int pLen, char * subStr, int sLen,
	int * solution, int solutionLen, int pStart, int subStart){

		if(solutionLen == sLen){
			for(int i = 0; i < solutionLen; ++i){
				std::cout << *(solution+i)<< " ";
			}	
			std::cout << std::endl;
			return;
		}

		for(int i = pStart; i < pLen; ++i){
			for(int j= subStart; j < sLen; ++j){
				if(pStr[i] == subStr[j]){
					solution[solutionLen] = i+1;
					GetSolution(pStr, pLen, subStr, sLen, solution, 
						solutionLen+1, i+1, j+1);
				}
			}
		}
}
};

#endif